<!DOCTYPE html>
<html class="x-admin-sm">

<head>
	<meta charset="UTF-8">
	<title>欢迎页面-X-admin2.2</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport"
		  content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
	<link rel="stylesheet" href="./css/font.css">
	<link rel="stylesheet" href="./css/xadmin.css">
	<script type="text/javascript" src="./lib/layui/layui.js"
			charset="utf-8"></script>
	<script type="text/javascript" src="./js/xadmin.js"></script>
	<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
	<!--[if lt IE 9]>
	<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
	<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
	<![endif]-->
</head>
<body>
<div class="layui-fluid">
	<div class="layui-row">
		<form class="layui-form">
			<input type="hidden" name="id" id="id"/>
			<div class="layui-form-item">
				<label for="professorName" class="layui-form-label"> <span
						class="x-red">*</span>专家姓名
				</label>
				<div class="layui-input-inline">
					<input type="text" id="professorName" name="professorName" lay-verify="professorName"
						   required="required" autocomplete="off" class="layui-input">
				</div>
				<div class="layui-form-mid layui-word-aux">
					<span class="x-red">*</span>
				</div>
			</div>
			<div class="layui-form-item">
				<label for="gender" class="layui-form-label">
					性别
				</label>
				<div class="layui-input-inline" style="margin-top: 8px;">
					<input type="checkbox" id="gender" name="gender" lay-skin = "switch" lay-text = "男|女" checked="checked" lay-filter = "gender" class="layui-input" />
				</div>
			</div>
			<div class="layui-form-item">
				<label for="birthday" class="layui-form-label">
					出生年月
				</label>
				<div class="layui-input-inline">
					<input  id="birthday" name="birthday"
							lay-verify="birthday" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label for="identityNumber" class="layui-form-label">
					身份证号
				</label>
				<div class="layui-input-inline">
					<input type="text" id="identityNumber" name="identityNumber"
						   lay-verify="identityNumber" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label for="workStatus" class="layui-form-label">
					工作状态
				</label>
				<div class="layui-input-inline">
					<select name="workStatus" id="workStatus">

					</select>

				</div>
			</div>
			<div class="layui-form-item">
				<label for="institution" class="layui-form-label">
					毕业院校
				</label>
				<div class="layui-input-inline">
					<input type="text" id="institution" name="institution"
						   lay-verify="institution" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label for="education" class="layui-form-label">
					学历
				</label>
				<div class="layui-input-inline">
					<select name="education" id="education">

					</select>

				</div>
			</div>
			<div class="layui-form-item">
				<label for="major" class="layui-form-label">
					专业
				</label>
				<div class="layui-input-inline">
					<input type="text" id="major" name="major"
						   lay-verify="major" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label for="employCompany" class="layui-form-label">
					工作单位
				</label>
				<div class="layui-input-inline">
					<input type="text" id="employCompany" name="employCompany"
						   lay-verify="employCompany" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label for="administrative" class="layui-form-label">
					行政职务
				</label>
				<div class="layui-input-inline">
					<select id="administrative" name="administrative">

					</select>

				</div>
			</div>
			<div class="layui-form-item">
				<label for="technicalPost" class="layui-form-label">
					技术职称
				</label>
				<div class="layui-input-inline">
					<select id="technicalPost" name="technicalPost">

					</select>

				</div>
			</div>
			<div class="layui-form-item">
				<label for="phone" class="layui-form-label">
					固定电话
				</label>
				<div class="layui-input-inline">
					<input type="text" id="phone" name="phone"
						   lay-verify="phone" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label for="mobliePhone" class="layui-form-label">
					手机号
				</label>
				<div class="layui-input-inline">
					<input type="text" id="mobliePhone" name="mobliePhone"
						   lay-verify="mobliePhone" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label for="address" class="layui-form-label">
					所在地址
				</label>
				<div class="layui-input-inline">
					<input type="text" id="address" name="address" placeholder="可以通过下方的选择或者直接输入"
						   lay-verify="address" autocomplete="off" class="layui-input">
				</div>
				<!-- start-->
				<div class="layui-form-item x-city" id="end">
					<!--<label class="layui-form-label">所在地址</label>-->
					<div class="layui-input-inline">
						<select name="province" id="province" lay-filter="province">
							<option value="">请选择省</option>
						</select>
					</div>
					<div class="layui-input-inline">
					<select name="city" id="city" lay-filter="city">
						<option value="">请选择市</option>
					</select>
				</div>
					<div class="layui-input-inline">
						<select name="area" id="area" lay-filter="area">
							<option value="">请选择县/区</option>
						</select>
					</div>
				</div>

				<!-- end -->
			</div>
			<div class="layui-form-item">
				<label for="projectCategory" class="layui-form-label">
					评审项目类型
				</label>
				<div class="layui-input-inline">
					<input type="text" id="projectCategory" name="projectCategory"
						   lay-verify="projectCategory" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label for="workDate" class="layui-form-label"> <span
						class="x-red"></span>工作年限
				</label>
				<div class="layui-input-inline">
					<input type="number" min="0" id="workDate" name="workDate"
						   lay-verify="workDate" autocomplete="off" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label  class="layui-form-label"></label>
				<label  class="layui-form-label"></label>
				<button class="layui-btn" lay-filter="edit" lay-submit="">更新</button>
			</div>
		</form>
	</div>
</div>
<script>layui.use([ 'form', 'laydate','layer', 'jquery' ],
    function() {
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer,
            laydate = layui.laydate;

        laydate.render({
            elem: '#enterdate' //指定元素
            , trigger: 'click'
        });
        // var $role=$("#role");
        // $.get("userGet.jhtml",function(data){
        //     $.each(data,function(i,d){
        //         $role.append(new Option(d.name,d.id));
        //     });
        //     form.render();//重绘表单
        // });
        var id=location.search.substring(1);
        //alert(id+">>>>>>>");
        $.get("professorGet",{id:id},function(p){
            for (var i in p.data) {
                $("#" + i).val(p.data[i]);
            }
            //role单独处理
            //$role.val(obj.role);
            //alert("obj role:"+obj.role);
            form.render();//重绘表单
        });
        //自定义验证规则
        form.verify({
            name : function(value) {
                if (value.length < 2||value.length >12) {
                    return '用户名必须是2-12个字符';
                }
            },
            password : [ /(.+){6,12}$/, '密码必须6到12位' ],
            repass : function(value) {
                if ($('#password').val() !=value) {
                    return '两次密码不一致';
                }
            }
        });

        //监听提交
        form.on('submit(edit)',
            function(data) {

                //alert("form data="+JSON.stringify(data.field));

                //发异步，把数据提交给
                $.post("professorUpdate",data.field,function(r){
                    if(r.msg){
                        //1.5秒后自动关闭
                        parent.layer.msg("修改成功", {
                            icon : 6,time:1500
                        },function(index,item){
                            xadmin.close();
                            // 可以对父窗口进行刷新
                            xadmin.father_reload();
                        });

                    }else{
                        parent.layer.alert("修改失败，请核对", {
                            icon : 1
                        });
                    }
                });

                return false;
            });

    });
</script>

</body>

</html>